import request from "../../utils/request.ts";
import {message} from 'antd';
import type {AxiosResponse} from 'axios'


//获取挂号列表
export const getRegisterList = async (params: any): Promise<any> => {
    try {
        const res: AxiosResponse<any, any> = await request.get('/register/list', params)
        if (res.data.code === 1) {
            return res.data
        }
        message.error(res.data.msg)
    } catch (err) {
        message.error('获取挂号列表失败')
        throw err
    }
}

//删除挂号单
export const delRegister = async (data: any): Promise<any> => {
    try {
        const res: AxiosResponse<any, any> = await request.post('/register/batchdel', data)
        if (res.data.code === 1) {
            message.success(res.data.msg)
            return res.data
        }
        message.error(res.data.msg)
    } catch (err) {
        message.error('删除挂号单失败')
        throw err
    }
}

//获取挂号单详情
export const getRegisterDetails = async (params: any): Promise<any> => {
    try {
        const res: AxiosResponse<any, any> = await request.get('/register/getbyid', params)
        if (res.data.code === 1) {
            return res.data
        }
        message.error(res.data.msg)
    } catch (err) {
        message.error('获取挂号单详情失败')
        throw err
    }
}


//查询挂号订单
export const getRegisterSearch = async (params: any): Promise<any> => {
    try {
        const res: AxiosResponse<any, any> = await request.get('/register/search', params)
        if (res.data.code === 1) {
            return res.data
        }
        message.error(res.data.msg)
    } catch (err) {
        message.error('查询挂号订单失败')
        throw err
    }
}